package dao

import (
	"WORKSPACE/models"
	"fmt"
)

func GetAllattendance() (error, []models.Attendance, int64) {
	var AttendanceData []models.Attendance
	//AttendanceData := []models.Attendance{{"1qwe",1,"1",1,1,1,1,1,}}
	var total int64
	fmt.Println(AttendanceData)
	err := db.Table("attendance").Order("eno ASC").Count(&total).Find(&AttendanceData).Error
	fmt.Println(AttendanceData)
	return err, AttendanceData, total
}

func Addattendance(attendance models.Attendance) error {
	err := db.Table("attendance").Create(&attendance).Error
	return err
}

func Updateattendance(attendance models.Attendance) error {
	err := db.Table("attendance").Where("eno = ? AND Adata = ?", attendance.Eno,attendance.Adata).Updates(attendance).Error
	return err
}

func Delattendance(id string,data string) error {
	err := db.Table("attendance").Where("Eno = ? AND Adata = ?", id,data).Delete(models.Attendance{}).Error
	return err
}